/*
 * HalcyonV1.h
 *
 * Created: 01.05.2012 12:28:46
 *  Author: maxim.karban@gmail.com
 */ 

#ifndef _smd500_h_
#define _smd500_h_

#include "HalcyonV1.h"

#include <avr/io.h>

#define BS_SELECT PORTC |= (1 << 2)
#define BS_DESELECT PORTC &= ~(1 << 2)
#define BS_SELECT PORTC |= (1 << 2)


#define SENSOR_UNKNOWN 0x00
#define SENSOR_BMP_085 0x01
#define SENSOR_SMD_500 0x02

#define BMP085_PROM_START__ADDR		0xaa
#define BMP085_PROM_DATA__LEN	        22

#define BMP085_CHIP_ID_REG	        0xD0
#define BMP085_VERSION_REG              0xD1

#define BMP085_CTRL_MEAS_REG		0xF4
#define BMP085_ADC_OUT_MSB_REG		0xF6
#define BMP085_ADC_OUT_LSB_REG		0xF7

#define BMP085_SOFT_RESET_REG		0xE0

#define BMP085_T_MEASURE                0x2E    // temperature measurent 
#define BMP085_P_MEASURE                0x34    // pressure measurement
#define SMD500_P_MEASURE                0xF4

#define SMD500_PARAM_M1     -2218        //calibration parameter
#define SMD500_PARAM_M2      -457        //calibration parameter
#define SMD500_PARAM_M3     -1984        //calibration parameter
#define SMD500_PARAM_M4      8808        //calibration parameter
#define SMD500_PARAM_M5       496        //calibration parameter
#define SMD500_PARAM_M6      1415        //calibration parameter

#define SMD500_PARAM_MB     -4955        //calibration parameter
#define SMD500_PARAM_MC     11611        //calibration parameter
#define SMD500_PARAM_MD    -12166        //calibration parameter
#define SMD500_PARAM_ME    -17268        //calibration parameter
#define SMD500_PARAM_MF     -8970        //calibration parameter

#define SMD500_PARAM_MG      3038        //calibration parameter
#define SMD500_PARAM_MH     -7357        //calibration parameter
#define SMD500_PARAM_MI      3791        //calibration parameter
#define SMD500_PARAM_MJ     64385        //calibration parameter

extern uint8_t BOSCH_TYPE;

extern unsigned char ByteBufferP[];
extern unsigned char ByteBufferT[];


extern uint16_t F1;
extern uint16_t F2;
extern uint16_t F3;
extern uint16_t F4;
extern volatile uint32_t UT;
extern volatile uint32_t UP;

extern volatile int32_t H;
extern volatile int32_t T;

extern void BSInit();
extern void BSReadCal();
extern void BSStartTemp();
extern void BSStartPress();
extern void BSReadTemp();
extern void BSReadPress();
extern void BSCalcAltitude();


#endif //_smd500_h_
